package com.aebiz.usercenter.util;

import java.util.Date;
import java.util.Iterator;
import java.util.Map.Entry;

import org.springframework.stereotype.Component;

import com.aebiz.usercenter.common.util.ConstatFinalUtil;
import com.aebiz.usercenter.common.util.DateFormatUtil;
import com.alibaba.fastjson.JSONObject;


@Component("timerUtil")
public class TimerUtil {

	/**
	 * 定时执行此方法 
	 */
	public void executTest(){
		ConstatFinalUtil.SYS_LOGGER.info(ConstatFinalUtil.ADMINS_MAP.size()+"--前--"+ConstatFinalUtil.ADMINS_MAP);
		DateFormatUtil dateFormatUtil=new DateFormatUtil();
		/*循环map移除token*/
		for (Iterator iterator = ConstatFinalUtil.ADMINS_MAP.entrySet().iterator(); iterator.hasNext();) {
			Entry entry = (Entry) iterator.next();
			
			String key=entry.getKey()+"";
			JSONObject adminsJSON=(JSONObject) entry.getValue();
			String verifyDataStr = adminsJSON.getString("verifyDate");
			/*超时时间*/
			Date veriftDate=dateFormatUtil.strDateTime(verifyDataStr);
			if(new Date().getTime()-veriftDate.getTime()>1000*60){
				/*移除操作*/
				ConstatFinalUtil.ADMINS_MAP.remove(key);
			}
		}
		ConstatFinalUtil.SYS_LOGGER.info(ConstatFinalUtil.ADMINS_MAP.size() + "--后--" + ConstatFinalUtil.ADMINS_MAP);
	}
}
